@echo off

set today=%date:~0,4%%date:~5,2%%date:~8,2%
set env=%1%
set projectName=%2%
set packageFolder=%3%
set webPath=%4%
set packagePath=%packageFolder%\%projectName%_%today%.7z
set rar="C:\Program Files\WinRAR\winrar.exe"
set zip="C:\Program Files\7-Zip\7z.exe"

echo "[Debug:info] projectName=%projectName%"
echo "[Debug:info] env=%env%"
echo "[Debug:info] packagePath=%packagePath%"
echo "[Debug:info] webPath=%webPath%"


IF "%webPath%" == "" (
	echo "[Error:info] not exists web path: %webPath%"
    GOTO ERROR
)

echo "[Debug:info] start unzip package to project folder: %webPath%"
::%rar% x %packagePath% C:\DevGasManager\dev.trunklpg
%zip% x %packagePath% -o%webPath% -aoa
IF %ERRORLEVEL% NEQ 0 GOTO ERROR

:OK
ECHO command success
EXIT 0

:ERROR
ECHO command failed
EXIT 1